﻿using DataContext;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Bauteileverwaltung.Views
{
    /// <summary>
    /// Interaction logic for StoreTree.xaml
    /// </summary>
    public partial class StoreTree : UserControl
    {
        public StoreTree()
        {
            InitializeComponent();
            

            DataContext = new { Stores = new StoreDao().GetAllRootStores() };
        }

        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item = (MenuItem)sender;

            StoreDao _dao = new StoreDao();

            switch ((String)item.Header)
            {
                case "Neues Lager":

                    break;
                case "Lager Löschen":
                    int storeID = Int32.Parse(item.CommandParameter.ToString());
                    _dao.DeleleStoreByIdOnCasecade(storeID);
                    DataContext = new { Stores = _dao.GetAllRootStores()};
                    break;
                default:
                    break;
            }

        }
    }
}
